home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / dflat_r_.arc / BUTTON.C < prev    next >
Text File  |  1991-10-02  |  2KB  |  73 lines

  1. /* -------------- button.c -------------- */
  2.  
  3. #include <conio.h>
  4. #include "dflat.h"
  5.  
  6. #ifdef INCLUDE_DIALOG_BOXES
  7.  
  8. int ButtonProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
  9. {
  10.     DBOX *db = GetParent(wnd)->extension;
  11.     CTLWINDOW *ct = ControlBox(db, wnd);
  12.     int x;
  13.     switch (msg)    {
  14.         case SETFOCUS:
  15.             BaseWndProc(BUTTON, wnd, msg, p1, p2);
  16.             /* ------- fall through ------- */
  17.         case PAINT:
  18.             if (isVisible(wnd))    {
  19.                 if (TestAttribute(wnd, SHADOW))    {
  20.                     /* -------- draw the button's shadow ------- */
  21.                     background = WndBackground(GetParent(wnd));
  22.                     foreground = BLACK;
  23.                     PutWindowChar(wnd, WindowWidth(wnd), 0, 220);
  24.                     for (x = 0; x < WindowWidth(wnd); x++)
  25.                         PutWindowChar(wnd, x+1, 1, 223);
  26.                 }
  27.                 /* --------- write the button's text ------- */
  28.                 WriteTextLine(wnd, NULL, 0, wnd == inFocus);
  29.             }
  30.             return TRUE;
  31.         case KEYBOARD:
  32. #ifdef INCLUDE_SYSTEM_MENUS
  33.             if (WindowMoving || WindowSizing)
  34.                 break;
  35. #endif
  36.             if (p1 == UP || p1 == BS)
  37.                 p1 = CTRL_FIVE, p2 = LEFTSHIFT;
  38.             if (p1 == DN || p1 == FWD)
  39.                 p1 = '\t';
  40.             if (p1 != '\r')
  41.                 break;
  42.             /* ---- fall through ---- */
  43.         case LEFT_BUTTON:
  44. #ifdef PUSHBUTTON_DEPRESS
  45.             /* --------- draw a pushed button -------- */
  46.             background = WndBackground(GetParent(wnd));
  47.             foreground = WndBackground(wnd);
  48.             PutWindowChar(wnd, 0, 0, ' ');
  49.             for (x = 0; x < WindowWidth(wnd); x++)    {
  50.                 PutWindowChar(wnd, x+1, 0, 220);
  51.                 PutWindowChar(wnd, x+1, 1, 223);
  52.             }
  53.             if (msg == LEFT_BUTTON)
  54.                 SendMessage(NULLWND, WAITMOUSE, 0, 0);
  55.             else
  56.                 SendMessage(NULLWND, WAITKEYBOARD, 0, 0);
  57.             SendMessage(wnd, PAINT, 0, 0);
  58. #endif
  59.             if (ct->setting == ON)
  60.                 PostMessage(GetParent(wnd), COMMAND, ct->command, 0);
  61.             else
  62.                 beep();
  63.             return TRUE;
  64.         case HORIZSCROLL:
  65.             return TRUE;
  66.         default:
  67.             break;
  68.     }
  69.     return BaseWndProc(BUTTON, wnd, msg, p1, p2);
  70. }
  71.  
  72. #endif
  73.